<?php
/**
 * Created by PhpStorm.
 * User: jiankian
 * Date: 2017/4/8
 * Time: 上午10:06
 */
namespace app\expbao\admin;
use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use app\expbao\model\ExRules as RuleModel;
class AdminApi extends Admin{
    public function index(){
    	$map = $this->getMap();
    	$aaa = RuleModel::where($map)->order('id asc')->paginate();
    	//$aaa=RuleModel::get(1);
    	//var_dump($aaa);
    	//echo $aaa->func;
    	 $page = $aaa->render();
    	return ZBuilder::make('table')
            ->setPageTitle('用户管理') // 设置页面标题
            ->setTableName('expbao_rules') // 设置数据表名
            ->setSearch(['id' => 'ID', 'member_name' => '用户名', 'member_email' => '邮箱']) // 设置搜索参数
            ->addColumns([ // 批量添加列
                ['id', 'ID'],
                ['func', '用户名'],
                ['pid', '昵称'],
                ['create_time', '注册时间', 'datetime'],
                ['state', '状态', 'switch'],
                ['right_button', '操作', 'btn']
            ])
            ->addTopButtons('add,enable,disable,delete') // 批量添加顶部按钮
            ->addRightButtons('edit,delete') // 批量添加右侧按钮
            ->setPrimaryKey('id') // 设置主键名为username
            ->setRowList($aaa) // 设置表格数据
            ->setPages($page) // 设置分页数据
            ->fetch(); // 渲染页面
        return $this->fetch();
    }
}